﻿
Namespace Compiler.Semantic
    Public Class SymbolBinder
        Inherits Binder

        Private m_symbol As Symbol
        Public Property Symbol() As Symbol
            Get
                Return m_symbol
            End Get
            Set(ByVal value As Symbol)
                m_symbol = value
            End Set
        End Property

        Public Sub New(ByVal symbol As Symbol)
            m_symbol = symbol
        End Sub

        Public Sub New(ByVal symbolName As String)
            m_symbol = Symbol.Get(symbolName)
        End Sub

        Public Overrides Function Equals(ByVal other As Binder) As Boolean
            If other Is Nothing Then Return False
            If Not TypeOf other Is SymbolBinder Then Return False

            Dim typedOther As SymbolBinder = TryCast(other, SymbolBinder)

            If typedOther.m_symbol.Equals(m_symbol) Then
                Return True
            Else
                Return False
            End If
        End Function

        Public Overrides Function GetHashCode() As Integer
            Return m_symbol.GetHashCode()
        End Function
    End Class
End Namespace